import 'package:flutter_module/res/image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';

class WelfareRankingDialog extends StatefulWidget {

  final String htmlContent;
  const WelfareRankingDialog({super.key, required this.htmlContent});

  @override
  State<WelfareRankingDialog> createState() => _WelfareRankingDialogState();

}

class _WelfareRankingDialogState extends State<WelfareRankingDialog> {
  @override
  Widget build(BuildContext context) {
    // 弹窗高度
    double dialogHeight = 506 * (MediaQuery.of(context).size.width / 375);
    return Container(
      height: dialogHeight,
      width: MediaQuery.of(context).size.width,
      margin: const EdgeInsets.symmetric(horizontal: 30.0),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(16),
        color: Colors.white,
      ),
      alignment: Alignment.center,
      child: Container(
        margin: const EdgeInsets.symmetric(horizontal: 20),
        child: Column(
          children: [
            Container(
              margin: const EdgeInsets.only(top: 24),
              child: Center(
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    SvgPicture.asset(YouthImages.icWelfareDialogLeftLogo),
                    const SizedBox(width: 6),
                    const Text(
                      '规则说明',
                      style: TextStyle(
                          fontSize: 16,
                          fontWeight: FontWeight.bold,
                          color: Color(0XFFd78c00)),
                    ),
                    const SizedBox(width: 6),
                    SvgPicture.asset(YouthImages.icWelfareDialogRightLogo),
                  ],
                ),
              ),
            ),
            Expanded(
              child: SingleChildScrollView(
                child:
                    // Html(
                    //   data: widget.htmlContent,
                    // ),
                    HtmlWidget(widget.htmlContent),
              ),
            ),
            GestureDetector(
              onTap: () => SmartDialog.dismiss(),
              child: Center(
                child: Container(
                  margin: const EdgeInsets.symmetric(vertical: 24),
                  width: 165,
                  height: 40,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(25),
                    gradient: const LinearGradient(
                      colors: [Color(0xFFFA8A14), Color(0xFFF65C15)],
                      begin: Alignment.centerLeft,
                      end: Alignment.centerRight,
                    ),
                  ),
                  child: const Center(
                    child: Text(
                      '我知道了',
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 15,
                      ),
                    ),
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
